package com.cardosystems.infra.pages;

import javax.swing.RepaintManager;

import jsystem.framework.analyzer.AnalyzerException;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class CardoCommunitySettingsPage extends CardoCommunitySiteFrame {

	@FindBy(xpath = "//label[@for=\"RDS\"]")
	WebElement rdsCheckbox;

	public CardoCommunitySettingsPage(WebDriver driver) throws Exception {
		super(driver);
		Thread.sleep(1000);

	}

	public boolean switchRdsState(boolean state) throws Exception {
		WebElement rdsDiv = rdsCheckbox.findElement(By.xpath(".."));
		boolean rdsState = rdsCheckbox.isSelected();
		if (state == true
				&& rdsDiv.getAttribute("class").equals(
						"check_settings_page checked")) {
			System.out.println("The RDS button is already on");
			return false;
		}
		if (state == false
				&& rdsDiv.getAttribute("class").equals(
						"check_settings_page unchecked")) {
			System.out.println("The RDS button is already off");
			return false;
		}

		rdsCheckbox.click();
		return true;
	}

}
